package zhihuilan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import zhihuilan.entity.MyCategoryProduct;

import java.util.List;

public interface MyCategoryProductMapper extends BaseMapper<MyCategoryProduct> {
    @Select({" <script> select * from my_category_product \n" +
            " where id in ( \n" +
            " select DISTINCT pid1 from my_factory_product \n" +
            " where shopid=#{shopId} and factoryid=0 and (price|price_z|price_q) > 0) \n" +
            " order by sort asc " +
            " </script>"})
    List<MyCategoryProduct> selectListToShopId(@Param("shopId") Integer shopId);

    @Select({" <script> select a.* from my_category_product a "+
            " where a.status=1 and a.isdelete=0 and a.pid=#{pid} "+
            " and exists (select b.pid1 from my_factory_product b where b.status = 1 and b.shopid=#{shopId} and b.factoryid=0 and b.price|b.price_q|b.price_z > 0 and b.pid1=a.id ) order by sort asc " +
            " </script>"})
    List<MyCategoryProduct> selectListToPid0(@Param("pid") Integer pid, @Param("shopId") Integer shopId);
    @Select({" <script> select a.* from my_category_product a "+
            " where a.status=1 and a.isdelete=0 and a.pid=#{pid} "+
            " and exists (select b.pid2 from my_factory_product b where b.status = 1 and b.shopid=#{shopId} and b.factoryid=0 and b.price|b.price_q|b.price_z > 0 and b.pid2=a.id ) order by sort asc " +
            " </script>"})
    List<MyCategoryProduct> selectListToPid1(@Param("pid") Integer pid, @Param("shopId") Integer shopId);
    @Select({" <script> select a.* from my_category_product a "+
            " where a.status=1 and a.isdelete=0 and a.pid=#{pid} "+
            " and exists (select b.pid3 from my_factory_product b where b.status = 1 and b.shopid=#{shopId} and b.factoryid=0 and b.price|b.price_q|b.price_z > 0 and b.pid3=a.id ) order by sort asc " +
            " </script>"})
    List<MyCategoryProduct> selectListToPid2(@Param("pid") Integer pid, @Param("shopId") Integer shopId);
    @Select({" <script> select a.* from my_category_product a "+
            " where a.status=1 and a.isdelete=0 and a.pid=#{pid} "+
            " and exists (select b.pid4 from my_factory_product b where b.status = 1 and b.shopid=#{shopId} and b.factoryid=0 and b.price|b.price_q|b.price_z > 0 and b.pid4=a.id ) order by sort asc " +
            " </script>"})
    List<MyCategoryProduct> selectListToPid3(@Param("pid") Integer pid, @Param("shopId") Integer shopId);
    @Select({" <script> select a.* from my_category_product a "+
            " where a.status=1 and a.isdelete=0 and a.pid=#{pid} "+
            " and exists (select b.pid5 from my_factory_product b where b.status = 1 and b.shopid=#{shopId} and b.factoryid=0 and b.price|b.price_q|b.price_z > 0 and b.pid5=a.id ) order by sort asc " +
            " </script>"})
    List<MyCategoryProduct> selectListToPid4(@Param("pid") Integer pid, @Param("shopId") Integer shopId);
}
